<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>显示</title>
    <style media="print">
        @page {
            size: auto;  /* auto is the initial value */
            margin: 0mm; /* this affects the margin in the printer settings */
        }
    </style>
    <script>
        function haha() {
            window.print();
        }
    </script>
</head>
<body>
<div>
    <div onclick="haha()">打印</div>
    你好啊
</div>
</body>
</html>